#!/usr/bin/env python

import os
import string
from tools import config

alert=False
max = config.getAlertMax ("loadavg")
min = config.getAlertMin ("loadavg")

def get() :
	""" """
	global alert
	global max
	global min
	try:
		f=os.popen("/usr/bin/uptime")
		cont=string.split(string.split(string.split(f.read(), "\n")[0], \
			"average:")[1], ",")
		f.close()
	except:
		return 0
	if float(cont[0]) > max or float(cont[0]) < min :
		alert = True
	else :
		alert = False
	return str (cont[0]) + " " + str (cont[1]) + " " + str (cont[2])

def getAlert() :
	global alert
	return alert
